﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Web.Script.Serialization;

namespace zUfDsl.Common
{
    public class HandleJSON
    {
        #region 反序列化对象
        /// <summary>
        /// 反序列化对象
        /// </summary>
        /// <param name="json"></param>
        /// <returns></returns>
        public static Dictionary<string, object> Deserialize(string json)
        {
            var js = new JavaScriptSerializer();
            js.MaxJsonLength = Int32.MaxValue; //取得最大数值
            return js.Deserialize<Dictionary<string, object>>(json);
        }

        public static T Deserialize<T>(string json)
        {
            var js = new JavaScriptSerializer();
            js.MaxJsonLength = Int32.MaxValue; //取得最大数值
            return js.Deserialize<T>(json);
        }


        #endregion

        #region 序列化对象
        /// <summary>
        /// 序列化对象
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static string Serialize(object obj)
        {
            var js = new JavaScriptSerializer();
            js.MaxJsonLength = Int32.MaxValue; //取得最大数值
            return js.Serialize(obj);
        }
        #endregion
    }
}
